//表单校验类：
class ValidForm {
    constructor() {
        this.emailReg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/
        this.nickNameReg = /^[\w\u4e00-\u9fa4]{1,20}$/
        this.pwdReg = /^[A-Za-z]\w{5,15}$/
        this.codeReg = /^[0-9A-Za-z]{6}$/
    }
    isValidEmail(value) {
        return this.emailReg.test(value)
    }
    isValidNickName(value) {
        return this.nickNameReg.test(value)
    }
    isPwd(value) {
        return this.pwdReg.test(value)
    }
    isValidCode(value) {
        return this.codeReg.test(value)
    }
}

//表单校验控件：
function valid(el, fn) {
    let validForm = new ValidForm()
    let value = $(el).val()
    // console.log(userEmail);
    if (!validForm[fn](value)) {
        $(el).next().show().attr('name', 1)
    } else {
        $(el).next().hide().removeAttr('name')
    }
}